-
Notifications
You must be signed in to change notification settings - Fork 66
Bxdf fixes cook torrance #930
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
#ifndef __HLSL_VERSION | ||
namespace std | ||
{ | ||
template<typename T, uint16_t N> | ||
struct hash<nbl::hlsl::vector<T,N> > | ||
{ | ||
size_t operator()(const nbl::hlsl::vector<T,N>& v) const noexcept | ||
{ | ||
size_t seed = 0; | ||
NBL_UNROLL for (uint16_t i = 0; i < N; i++) | ||
nbl::core::hash_combine(seed, v[i]); | ||
return seed; | ||
} | ||
}; | ||
|
||
template<typename T> | ||
struct hash<nbl::hlsl::vector<T,1> > | ||
{ | ||
size_t operator()(const nbl::hlsl::vector<T,1>& v) const noexcept | ||
{ | ||
std::hash<T> hasher; | ||
return hasher(v.x); | ||
} | ||
}; | ||
} | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you sure having this specialization globally is a good idea ?
What do you use it for ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also used in the bucket bxdf test, for hash map buckets
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then define it in that example, nowhere else
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved this over from the test due to this comment
Devsh-Graphics-Programming/Nabla-Examples-and-Tests#165 (comment)
N ndf; | ||
F fresnel; | ||
}; | ||
|
||
template<class Config, class N, class F> | ||
NBL_PARTIAL_REQ_TOP(config_concepts::MicrofacetConfiguration<Config> && ndf::NDF<N> && fresnel::Fresnel<F>) | ||
struct SCookTorrance<Config, N, F, true NBL_PARTIAL_REQ_BOT(config_concepts::MicrofacetConfiguration<Config> && ndf::NDF<N> && fresnel::Fresnel<F>) > | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any chance at inheriting from a common base for both BRDF and BSDF, so that we don't have so much duplicate code (BRDF and BSDF only differ in how they factor the reflectance into the generation and pdf)
static this_t create(scalar_type A, NBL_CONST_REF_ARG(spectral_type) eta, NBL_CONST_REF_ARG(spectral_type) etak) | ||
{ | ||
this_t retval; | ||
retval.__base.ndf.__base.A = vector2_type(A, A); | ||
retval.__base.ndf.__base.a2 = A*A; | ||
retval.__base.fresnel.ior = ior0; | ||
retval.__base.fresnel.iork = ior1; | ||
retval.__base.fresnel.iork2 = ior1*ior1; | ||
retval.__base.fresnel.eta = eta; | ||
retval.__base.fresnel.etak2 = etak * etak; | ||
retval.__base.fresnel.etaLen2 = eta * eta + retval.__base.fresnel.etak2; | ||
return retval; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are you assuming the fresnel used ?
spectral_type ior0; | ||
spectral_type ior1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you need to pass the fresnel already set up
return create(params.A, params.ior0, params.ior1); | ||
return create(params.A, params.eta, params.etak); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do all these still exist and aren't just typedefs for Cook Torrance ?
sample_type generate(NBL_CONST_REF_ARG(isotropic_interaction_type) interaction, const vector2_type u) | ||
{ | ||
return __base.generate(anisotropic_interaction_type::create(interaction), u); | ||
return __base.template generate<vector2_type>(anisotropic_interaction_type::create(interaction), u); | ||
} | ||
sample_type generate(NBL_CONST_REF_ARG(anisotropic_interaction_type) interaction, const vector2_type u) | ||
{ | ||
return __base.generate(interaction, u); | ||
return __base.template generate<vector2_type>(interaction, u); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not just typedef instead of writing pointless passthrough class ?
{ | ||
quant_type G2 = ndf.template correlated<sample_type, isotropic_interaction_type>(gq, qq, _sample, interaction); | ||
DG *= G2.microfacetMeasure; | ||
DG *= ndf.template correlated<sample_type, isotropic_interaction_type>(gq, _sample, interaction); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lower the gq
creation as well
{ | ||
quant_type G2 = ndf.template correlated<sample_type, anisotropic_interaction_type>(gq, qq, _sample, interaction); | ||
DG *= G2.microfacetMeasure; | ||
DG *= ndf.template correlated<sample_type, anisotropic_interaction_type>(gq, _sample, interaction); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lower the gq
creation as well
…ction/cache versions
…ook torrance template
…y moved into base
…nctionality moved into base
Description
Continues #899 , #916 and #919
Testing
TODO list: